package com.ruoyi.system.service.impl;

import com.ruoyi.system.domain.SysUnit;
import com.ruoyi.system.mapper.SysUnitMapper;
import com.ruoyi.system.service.SysUnitService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class SysUnitServiceImpl implements SysUnitService {
    @Autowired
    SysUnitMapper mapper;
    @Override
    public List<SysUnit> queryAll(SysUnit unit) {
        return mapper.queryAll(unit);
    }

    @Override
    public int insert(SysUnit unit) {
        String code=mapper.queryMaxCode();
        if(code==null){
            unit.setCode("300101");
        }else {
            unit.setCode(Integer.parseInt(code)+1+"");
        }
        return mapper.insert(unit);
    }
}
